const KoaRouter = require("@koa/router");
const { commonValidator } = require("../middleware/global.middleware");
const Joi = require("joi");
const { signToken } = require("../controller/login.controller");
const { verifyUserLogin } = require("../middleware/login.middleware");

// 创建登录路由
const loginRouter = new KoaRouter({ prefix: "/login" });
loginRouter.post(
  "/",
  commonValidator({
    name: Joi.string().required(),
    password: Joi.string().required(),
  }),
  verifyUserLogin,
  signToken
);

module.exports = loginRouter;
